let time = new Date(); //时间标准格式
// console.log(time)

// let Y = time.getFullYear();
// let M = time.getMonth() + 1;
// // let D = time.getDay();    //星期几
// let D = time.getDate();

// let hh = time.getHours();
// let mm = time.getMinutes();
// let ss = time.getSeconds();

// M = M < 10 ? M.toString().padStart(2,"0") : M;
// D = D < 10 ? D.toString().padStart(2,"0") : D;

let obj = {
  Y: time.getFullYear(),
  M: time.getMonth() + 1,
  D: time.getDate(),
  hh: time.getHours(),
  mm: time.getMinutes(),
  ss: time.getSeconds(),
};
// console.log(obj)
for (let k in obj) {
  obj[k] = obj[k] < 10 ? obj[k].toString().padStart(2, "0") : obj[k];
}
// console.log(obj)


let str = `${obj.Y}-${obj.M}-${obj.D} ${obj.hh}:${obj.mm}:${obj.ss}`;
console.log(str);

//对象循环
// let obj = {
//   name: "张三",
//   age: 21,
//   address: "北京",
// };

// for(let k in obj){
//   // console.log(k)
//   console.log(obj[k])
// }

// //字符串处理
// let str="北京 你好";
// let arr=str.split(" ")
// // console.log(arr)
// str=arr.join("")
// console.log(str)

// let str = "北京";
// let result = str.padStart(6, "欢");
// let result=str.padEnd(6,"好")
// console.log(result)
